<?php
/**
 * Created by PhpStorm.
 * User: 明哲
 * Date: 2016/4/29
 * Time: 11:07
 */
include('../../config.php');

$current_time=date('Y-m-d H:i:s',time());
$action = $_GET['action'];
$type = $_GET['type'];
$page = $_GET['page'];
$number = 10;
$min=$page*$number-$number;

$username=$_GET['username'];
$password=$_GET['password'];

$del_id = $_GET['del_id'];

switch($action){
    default :
        $rows=$mysql->query("select * from `user` where `type`= {$type} order by id  limit {$min},{$number}");
        if($rows){
            $rows =json_encode($rows);
            echo $rows;
        }else{
            echo 0;
        }
        break;
    case 'add' :
        $rows=$mysql->query("insert into `user` VALUES(null,'{$username}','{$password}','{$current_time}')");
        echo 1;
        break;
    case 'del' :
        $rows=$mysql->query("delete from `user` where `id`='{$del_id}'");
        echo 1;
        break;
    case 'edit' :
        break;
}
